package com.the4man.framework.util.io;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;

/**
 * Created by lenovo on 2017/12/12.
 */
public class FileWriteHandler {
    private static final Logger logger = LoggerFactory.getLogger(FileWriteHandler.class);
    private FileOutputStream fileOutputStream = null;
    private Writer utfWrite = null;

    public FileWriteHandler(String dataDir, String fileName) {
        try {
            FileUtil fileUtil = new FileUtil();
            fileUtil.createFolder(dataDir);
            this.fileOutputStream = new FileOutputStream(fileName);
            this.utfWrite = new OutputStreamWriter(this.fileOutputStream, "utf-8");
        } catch (Exception var4) {
            logger.error("写入异常", var4);
        }

    }

    public FileWriteHandler(String fileName) {
        try {
            this.fileOutputStream = new FileOutputStream(fileName);
            this.utfWrite = new OutputStreamWriter(this.fileOutputStream, "gbk");
        } catch (Exception var3) {
            var3.printStackTrace();
        }

    }
}
